<template>
	<view class="used">
		<view class="head">
			<view class="search">
				<image @click="back" class="arrows" src="../../static/箭头左.png" mode=""></image>
				<input type="text" v-model="find" placeholder="找活、找工作" />
				搜索
			</view>
			<view class="classify">
				<view @click="showPopup" class="region">
					北京
					<image src="../../static/下箭头.png"></image>
					<my-tree :show="showAddress"></my-tree>
				</view>
				<view class="type">
					全部
					<image src="../../static/下箭头.png"></image>
				</view>
				<view class="recommend">
					最新
					<image src="../../static/下箭头.png"></image>
				</view>
			</view>
		</view>

		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<view class="marge">
				<view @click="open">
					<contact-way class="module" style="margin-top: 0rpx;"></contact-way>
					<my-relation ref="popup"></my-relation>
				</view>
				<view class="advisory">
					<view class="advisory-fish">鱼泡资讯：</view>
					<swiper vertical="true" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000">
						<swiper-item>
							<view class="swiper-item">Aasdddddddddddddddddddddddddddddddddddddddddd</view>
						</swiper-item>
						<swiper-item>
							<view class="swiper-item">B</view>
						</swiper-item>
					</swiper>
				</view>
			</view>
			<view v-for="message in messages" :key="message.id">
				<view @click="goMessage">
					<my-used :people="message"></my-used>
				</view>
			</view>
		</mescroll-body>

	</view>
</template>

<script>
	import myUsed from '../../components/my-used.vue'
	import mescrollMixin from '../../components/mescroll-uni/mescroll-mixins.js';
	import mescrollBody from '../../components/mescroll-uni/mescroll-body.vue';
	import contactWay from '../../components/contactway.vue';
	import drawPopup from '../../components/draw.vue';
	import myTree from '../../components/tree.vue'
	import myRelation from '../../components/relation.vue'
	export default {
		name: "employment",
		mixins: [mescrollMixin],
		data() {
			return {
				find: "",
				animationData: {},
				animationDataJob: {},
				downOption: {},
				temp: true,
				show: false,
				showAddress: false,
				overclass: "请选择",
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					}
				},
				messages: [{
						id: 1,
						image: "../../static/首页ok_29-17.jpg",
						name: "李先生",
						address: "广州",
						time: "2020-10-15 10:03",
						status: "未成交"
					},

					{
						id: 2,
						image: "../../static/首页ok_29-17.jpg",
						name: "李先生",
						address: "广州",
						time: "2020-10-15 10:03",
						status: "未成交"
					},
					{
						id: 3,
						image: "../../static/首页ok_29-17.jpg",
						name: "李先生",
						address: "广州",
						time: "2020-10-15 10:03",
						status: "未成交"
					},

					{
						id: 4,
						image: "../../static/首页ok_29-17.jpg",
						name: "李先生",
						address: "广州",
						time: "2020-10-15 10:03",
						status: "未成交"
					},
				]
			}
		},
		components: {
			'myUsed': myUsed,
			'mescrollBody': mescrollBody,
			'contactWay': contactWay,
			'drawPopup': drawPopup,
			'myTree': myTree,
			'myRelation':myRelation
		},
		methods: {
			goMessage() {
				uni.navigateTo({
					url: "message"
				})
			},
			open() {
				this.$refs.popup.$refs.popups.open()
			},
			copy() {
				let self = this
				uni.setClipboardData({
					data: self.weChatNumb,
					success: function() {
						console.log("已复制" + self.weChatNumb)
					}
				})
			},
			upCallback(page) {
				let self = this.messages
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				let time = 2000;
				uni.request({
					url: 'xxxx?pageNum=' + pageNum + '&pageSize=' + pageSize,
					success: (data) => {
						// 接口返回的当前页数据列表 (数组)
						let curPageData = 2;
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = curPageData.length;
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = 2;
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
						let totalSize = 2;
						// 接口返回的是否有下一页 (true/false)
						let hasNext = false;

						//设置列表数据
						if (page.num == 1) self.messages = []; //如果是第一页需手动置空列表
						self.messages = self.messages.concat(curPageData); //追加新数据

						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);

						setTimeout(() => {
							this.mescroll.endSuccess(curPageLen)
						}, 2000)
					},
					fail: () => {
						//  请求失败,隐藏加载状态

						this.mescroll.endErr()
					},
				})

			},
			person(id) {
				uni.navigateTo({
					url: "/pages/employment/person?id=" + id
				})
			},
			share() {
				this.show = true;
			},
			release(phone) {
				uni.navigateTo({
					url: "/pages/employment/release?phone=" + phone
				})
			},
			showPopup() {
				this.showAddress = true;
			},
			exhibition(show) {
				this.show = show
			},
			employmentTree(show) {
				this.showAddress = show;
			},
			back() {
				uni.navigateBack()
			},

		},
	}
</script>

<style lang="scss" scoped>
	.used {
		width: 100vw;
		display: flex;
		flex-direction: column;
		background: #eaeaea;

		.head {
			position: fixed;
			background: #0497ff;
			padding: 60rpx 50rpx 0 20rpx;
			margin-bottom: 30rpx;
			z-index: 8;

			.search {
				display: flex;
				color: #FFFFFF;
				font-size: 32rpx;
				justify-content: space-between;
				align-items: center;
				margin-right: 30rpx;

				.arrows {
					width: 50rpx;
					height: 50rpx;

				}

				input {
					padding-right: 20rpx;
					padding-left: 10rpx;
					background-color: #FFFFFF;
					color: black;
					width: 60vw;
					border-radius: 10rpx;
					height: 60rpx;
				}
			}

			.classify {
				display: flex;
				justify-content: space-between;
				background: #FFFFFF;
				margin-top: 6rpx;
				align-items: center;
				width: 100vw;
				margin-left: -20rpx;

				image {
					width: 30rpx;
					height: 30rpx;
					margin-left: 10rpx;
				}

				.region,
				.type,
				.recommend {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 20vw;
					height: 6vh;
				}
			}
		}

		.invitation {
			display: flex;
			flex-direction: column;
			position: fixed;
			top: 100vw;
			right: 40rpx;
			z-index: 5;
			color: #007AFF;
			font-weight: bold;

			.invitation-image {

				width: 140rpx;
				height: 140rpx;
				border-radius: 20rpx;
				background: #007AFF;
				margin-bottom: 10rpx;

				image {
					width: 140rpx;
					height: 140rpx;
				}
			}
		}

		.marge {
			display: flex;
			flex-direction: column;
			background: #FFFFFF;
			margin-bottom: 20rpx;
			margin-top: 220rpx;
			// .module /deep/ .massage{
			// 	margin-top: 210rpx;
			// }

			.advisory {
				height: 6vh;
				display: flex;
				margin-top: 10rpx;
				font-size: 26rpx;
				margin-left: 20rpx;

				.advisory-fish {
					color: #F0AD4E;
					line-height: 40rpx;
				}

				swiper {
					height: 4vh;
					width: 560rpx;

					.swiper-item {
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}
		}
	}
</style>
